package com.googlecode.jlogindexer;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

import org.apache.commons.io.IOUtils;

public class ServerLogSimulator {

	public static void main(String[] args) {
		
		ServerLogSimulator simulator=new ServerLogSimulator();
		simulator.simulate();

	}	

	private void simulate()  {

		File dummyServerLogFile=new File("/Users/Jason/projects/JLogalizerClient/test/access.log");
		FileReader fileReader=null;
		PrintWriter printWriter=null;
		try {
			fileReader=new FileReader(dummyServerLogFile);
			BufferedReader buffReader=new BufferedReader(fileReader);
			
			File serverLog =new File("/Users/Jason/tmp/server.log");
			printWriter=new PrintWriter(serverLog);
			
			
			String currentLine;
			while ((currentLine=buffReader.readLine())!=null){
				
				printWriter.println(currentLine);
			}
			printWriter.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			IOUtils.closeQuietly(fileReader);
			IOUtils.closeQuietly(printWriter);
			e.printStackTrace();
		}
		
	}

}
